<?php
 class text
 {
     public static function simditor($zym_7)
     {
         return $zym_7;
     }
     public function clearSpace($zym_8)
     {
         $zym_8 = strip_tags($zym_8);
         $zym_8 = str_replace(array("\r", "\n", "\t", '"', "'"), ' ', $zym_8);
         while (strpos($zym_8, '  ') !== false) {
             $zym_8 = str_replace('  ', ' ', $zym_8);
         }
         return trim($zym_8);
     }
     public static function safetext($zym_9, $zym_6 = null)
     {
         $zym_9 = trim($zym_9);
         $zym_9 = preg_replace('/<!--?.*-->/', '', $zym_9);
         $zym_9 = preg_replace('/<\?|\?' . '>/', '', $zym_9);
         $zym_9 = preg_replace('/<script?.*\/script>/', '', $zym_9);
         $zym_9 = str_replace('[', '&#091;', $zym_9);
         $zym_9 = str_replace(']', '&#093;', $zym_9);
         $zym_9 = str_replace('|', '&#124;', $zym_9);
         $zym_9 = preg_replace('/<br(\s\/)?' . '>/i', '[br]', $zym_9);
         $zym_9 = preg_replace('/<p(\s\/)?' . '>/i', '[br]', $zym_9);
         $zym_9 = preg_replace('/(\[br\]\s*){10,}/i', '[br]', $zym_9);
         while (preg_match('/(<[^><]+)( lang|on|action|background|codebase|dynsrc|lowsrc)[^><]+/i', $zym_9, $zym_5)) {
             $zym_9 = str_replace($zym_5[0], $zym_5[1], $zym_9);
         }
         while (preg_match('/(<[^><]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^><]*)/i', $zym_9, $zym_5)) {
             $zym_9 = str_replace($zym_5[0], $zym_5[1] . $zym_5[3], $zym_9);
         }
         if (empty($zym_6)) {
             $zym_6 = 'br';
         }
         $zym_9 = preg_replace('/<(' . $zym_6 . ')( [^><\[\]]*)>/i', '[\1\2]', $zym_9);
         $zym_9 = preg_replace('/<\/(' . $zym_6 . ')>/Ui', '[/\1]', $zym_9);
         $zym_9 = preg_replace('/<\/?(html|head|meta|link|base|basefont|body|bgsound|title|style|script|form|iframe|frame|frameset|applet|id|ilayer|layer|name|script|style|xml|table|td|th|tr|i|u|strong|img|p|br|div|strong|em|ul|ol|li|dl|dd|dt|a)[^><]*>/i', '', $zym_9);
         while (preg_match('/<([a-z]+)[^><\[\]]*>[^><]*<\/\1>/i', $zym_9, $zym_5)) {
             $zym_9 = str_replace($zym_5[0], str_replace('>', ']', str_replace('<', '[', $zym_5[0])), $zym_9);
         }
         while (preg_match('/(\[[^\[\]]*=\s*)(\"|\')([^\2=\[\]]+)\2([^\[\]]*\])/i', $zym_9, $zym_5)) {
             $zym_9 = str_replace($zym_5[0], $zym_5[1] . '|' . $zym_5[3] . '|' . $zym_5[4], $zym_9);
         }
         while (preg_match('/\[[^\[\]]*(\"|\')[^\[\]]*\]/i', $zym_9, $zym_5)) {
             $zym_9 = str_replace($zym_5[0], str_replace($zym_5[1], '', $zym_5[0]), $zym_9);
         }
         $zym_9 = str_replace('<', '&lt;', $zym_9);
         $zym_9 = str_replace('>', '&gt;', $zym_9);
         $zym_9 = str_replace('"', '&quot;', $zym_9);
         $zym_9 = str_replace('[', '<', $zym_9);
         $zym_9 = str_replace(']', '>', $zym_9);
         $zym_9 = str_replace('|', '"', $zym_9);
         $zym_9 = str_replace('  ', ' ', $zym_9);
         return $zym_9;
     }
     public static function formattext($zym_7)
     {
         $zym_7 = str_ireplace(array('<br/>', '<br />', '<br>', '&#10;'), "\n", $zym_7);
         $zym_7 = str_replace("\r", "\n", $zym_7);
         do {
             $zym_7 = str_replace("\n\n", "\n", $zym_7);
         } while (strpos($zym_7, "\n\n") !== false);
         $zym_7 = trim(str_replace(array('　', '&nbsp;'), ' ', $zym_7));
         $zym_7 = strip_tags(self::safetext($zym_7));
         $zym_7 = str_replace("\n", "\r\n", trim($zym_7));
         return $zym_7;
     }
 }
